home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Sound
/
SoundEffects 0.9.2
/
SoundEffects Developer’s Kit
/
Interfaces
/
ModGetSetSamples.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-19
|
837b
|
33 lines
#include "ModGetSetSamples.h"
signed long GetSample16(Ptr samplePtr, short bps)
{
signed long mySample;
short byte, numBytes, sampleSize;
sampleSize = bps/8 + (bps%8 != 0);
numBytes = (sampleSize < sizeof(long)) ? sampleSize : sizeof(long);
for (byte = 0; byte < numBytes; byte++)
*(unsigned char *)((long)&mySample+byte) = *(unsigned char *)(samplePtr+byte);
mySample = mySample >> (sizeof(long)-numBytes) * 8;
return mySample;
}
void SetSample16(Ptr samplePtr, signed long mySample, short bps)
{
Ptr myPtr;
short byte, numBytes, sampleSize;
sampleSize = bps/8 + (bps%8 != 0);
numBytes = (sampleSize < sizeof(long)) ? sampleSize : sizeof(long);
myPtr = samplePtr;
for (byte = sizeof(long)-numBytes; byte < sizeof(long); byte++)
*(unsigned char *)myPtr++ = *(unsigned char *)((long)&mySample+byte);
}